﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 计算器
{
    public partial class Re : Form
    {
        public Form1 father;
        public Re()
        {
            InitializeComponent();
            this.StartPosition=FormStartPosition.CenterScreen;
            this.FormBorderStyle = FormBorderStyle.None;
        }

        private void Re_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int i = 0;
            while (i < father.wrong)
            {
                int j = i % 15;
                int k = (i + 15 - j) / 15 - 1;
                this.Controls.Add(father.wronglist[i].qulabel);
                father.wronglist[i].qulabel.Location = new System.Drawing.Point(100 * k + 10, 20 * j + 10);
                father.wronglist[i].qulabel.Size = new System.Drawing.Size(50, 20);
                this.Controls.Add(father.wronglist[i].youranswer);
                father.wronglist[i].youranswer.Location = new System.Drawing.Point(100 * k + 60, 20 * j + 10);
                father.wronglist[i].youranswer.Size = new System.Drawing.Size(40, 18);
                father.wronglist[i].youranswer.Text = "";
                father.wronglist[i].youranswer.BackColor = Color.White;
                i++;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int wrong = father.wrong;
            List<Ques> rightlist=new List<Ques>();
          for(int i=0;i<wrong;i++)
            {
                if (father.wronglist[i].youranswer.Text.Trim().Length == 0)
                {
                    //Ques q = father.wronglist[i];
                    father.wronglist[i].youranswer.BackColor = Color.Red;
                }
                else if (father.wronglist[i].youranswer.Text == father.wronglist[i].rightanswer.ToString())
                {
                    rightlist.Add(father.wronglist[i]);
                   // Ques q = father.wronglist[i];
                    //father.wronglist.Remove(q);
                    father.wrong--;
                }
                else
                {
                    father.wronglist[i].youranswer.BackColor = Color.Red;
                }
            }
            foreach(Ques item in rightlist)
            {
                father.wronglist.Remove(item);
            }
            string s = "共" + wrong.ToString() + "题，答错" +father.wrong.ToString() + "题";
            MessageBox.Show(s);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
            return;
        }
    }
}
